﻿@model IEnumerable<DFYE.Web.Models.guestBook>
@using JULONG.WEB.Library;
@using DFYE.Web.Models;
@{

    student st = ViewBag.student as student;
    
    ViewBag.Title = "留言";
    paging paging = new paging();
    paging.pageSize = 15;
    dynamic pagingMode;
    var vModel = paging.content(
        Model.OrderByDescending(d=>d.datetime),
        out pagingMode, Html.getRoute("page").As<int>()
        );
    ViewBag.paging = pagingMode;
}
<style>
    .userReply
    {
        padding:8px;
        padding-left:22px;color:#338d1a; 
    }
    .manageReply
    {
        padding:8px;
        padding-left:22px;color:#ff6a00;
    }
    .dateTitle
    {
        font-size:18px; font-family:'Courier New';color:gray;
    }

</style>
<div style="float:left; margin-right:20px;width:200px;">
        <img alt="" src="/Content/images/studentsDailyTitle.jpg" />
        <a href="/students/" class="linkBtn">学生日志</a>
        <a href="/students/guestbook/" class="linkBtn">家长留言</a>
        <div style="padding-left:20px; padding-top:20px; background:url(/content/images/userinfobg.gif);width:164px; height:123px; color:#fff;">
	        姓名：<span>@st.name</span>
            <br />
            生日：
                @if (st.birthday != null)
                {
                    @st.birthday.Value.ToString("yyyy年 MM月 dd日");
                }
                
@*            <h2><img src="@Model.pic" /></h2>*@
            <br />
            <h3><a href="/students/loginOff">退出</a></h3>
        </div>
        

</div>
<div style="padding-left:200px">
<div class="nav" style=" text-align:right">
    <span style="padding-right:20px">留言板</span>
    <div style="background:url(/Content/images/titleLine.png); background-position:right; background-repeat:no-repeat; height:9px; width:586px; border:0px solid red; overflow:hidden;"></div>
</div>
<div>
    

@foreach (var item in Model) {

    <div style="padding-top:5px;">
        <span class="dateTitle">
            @item.datetime.ToString("yyyy-MM-dd")
        </span>
        <div style="padding-left:60px" id="replyContent@(item.ID)">
            @Html.Raw(item.content)
        </div>

        <div style="text-align:right;">
            @Html.DisplayFor(modelItem => item.replyDatetime)
        <span>
            @if (!item.able) {
                <span>有新回复</span>;
            }

        </span>
            <a href='###' onclick='$("#replyGb@(item.ID)").show()' >回复</a>
        </div>
        <div style="display:none" id="replyGb@(item.ID)" >
            <input type="hidden" name="ID" value="@item.ID" />
            留言：
            <textarea name="content" style="background:url(/Content/images/txtareaBg.gif) 0px -54px; width:470px; height:18px; border:0px; overflow:hidden; padding:18px 4px 4px 4px"  ></textarea>
            <button type="button" onclick="replySubmit(this,@item.ID)">提交</button>
        </div>



    </div>
        <hr />
}
<script>
    function replySubmit(it, id) {
        var v = $(it).prev().val();
        if (v == "" && v.trim()=="") { return; }
        $.post("/students/replyGuestbook", { id: id, content: '[div class="userReply"][div class="replyDate"]{datetime}[/div][div class="replayContent"]' + v + '[/div][/div]' }, function (json) {
            if (json.result = "SUCCESS") {
                var _x = $("#replyContent" + id);
                _x.html(_x.html() + json.content);
            }
            
        })
    }
</script>

@Html.Partial("paging", new { action = "Index" })
<div class="clearFloat" ></div>
    <form action="/students/addguestBook" method="post">给老师留言：<textarea name="content" style="background:url(/Content/images/txtareaBg.gif) 0px 0px; width:470px; height:46px; border:0px; overflow:hidden; padding:4px;" ></textarea> <button>提交</button></form></div>
    </div>